package com.fsh.service.impl;

import com.fsh.mapper.UserMapper;
import com.fsh.pojo.Result;
import com.fsh.pojo.User;
import com.fsh.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> queryAll() {
        return userMapper.queryAll();
    }

    @Override
    public Integer addOne(User user) {
        return userMapper.addOne(user);
    }

    @Override
    public Integer delById(Integer id) {
        return userMapper.delById(id);
    }

    @Override
    public Integer updateById(User user) {
        return userMapper.updateById(user);
    }

    @Override
    public Page<User> pageList(Integer start, Integer pageSize) {
        //设置分页参数
        PageHelper.startPage(start,pageSize);
        //执行查询
        List<User> users = userMapper.pageList();//只要进行正常的查询，其他的全都不用管
        //强转为Page类型，里面封装着分页结果
        Page<User> p=(Page<User>) users;

        return p;
    }
}
